﻿using System.Collections.Generic;

namespace Zeus.Pattern.Observer
{
    public class BaseSubject : ISubject
    {
        private List<IObserver> observers = new List<IObserver>();

        public virtual void Attach(IObserver observer)
        {
            observers.Add(observer);
        }

        public virtual void Detach(IObserver observer)
        {
            observers.Remove(observer);
        }

        public virtual void NotifyObservers()
        {
            foreach (IObserver observer in observers)
            {
                observer.Update();
            }
        }
    }
}
